#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
//    //实例检测两次输入密码是否一致
//    ui->lineEdit->setEchoMode(QLineEdit::Password);
//    ui->lineEdit_2->setEchoMode(QLineEdit::Password);

    //实例：点击选项显示密码按钮可以显示密码
    ui->lineEdit->setEchoMode(QLineEdit::Password);
}

Widget::~Widget()
{
    delete ui;
}

//void Widget::campare()
//{
//    const QString& s1 = ui->lineEdit->text();
//    const QString& s2 = ui->lineEdit_2->text();
//    if(s1.isEmpty()&&s2.isEmpty())
//    {
//        ui->label->setText("有输入框为空！");
//    }
//    else if(s1==s2)
//    {
//        ui->label->setText("两次输入密码正常！");
//    }
//    else
//    {
//        ui->label->setText("两次密码不一致！");
//    }
//}


//void Widget::on_lineEdit_textEdited(const QString &arg1)
//{
//    (void)arg1;
//    this->campare();
//}

//void Widget::on_lineEdit_2_textEdited(const QString &arg1)
//{
//    (void)arg1;
//    this->campare();
//}

void Widget::on_checkBox_toggled(bool checked)
{
    if(checked)
    {
        ui->lineEdit->setEchoMode(QLineEdit::Normal);
    }
    else
    {
        ui->lineEdit->setEchoMode(QLineEdit::Password);
    }
}
